#include "STC8xxxx.H"
#include "intrins.h"

#ifdef USE_MDU16
uint8_t cror(uint8_t data, uint8_t sft)
{
    MD3 = data;
    ARCON = RIGHT_SHIFT + sft;
    OPCON = 1;
    while((OPCON & 1) != 0);
    return MD3;
}

uint16_t iror(uint16_t data, uint8_t sft)
{
    MD3U16 = data;
    ARCON = RIGHT_SHIFT + sft;
    OPCON = 1;
    while((OPCON & 1) != 0);
    return MD3U16;
}

uint32_t lror(uint32_t data, uint8_t sft)
{
    MD3U32 = data;
    ARCON = RIGHT_SHIFT + sft;
    OPCON = 1;
    while((OPCON & 1) != 0);
    return MD3U32;
}

uint8_t crol(uint8_t data, uint8_t sft)
{
    MD3 = data;
    ARCON = LEFT_SHIFT + sft;
    OPCON = 1;
    while((OPCON & 1) != 0);
    return MD3;
}

uint16_t irol(uint16_t data, uint8_t sft)
{
    MD3U16 = data;
    ARCON = LEFT_SHIFT + sft;
    OPCON = 1;
    while((OPCON & 1) != 0);
    return MD3U16;
}

uint32_t lrol(uint32_t data, uint8_t sft)
{
    MD3U32 = data;
    ARCON = LEFT_SHIFT + sft;
    OPCON = 1;
    while((OPCON & 1) != 0);
    return MD3U32;
}

uint32_t mul16(uint16_t A, uint16_t B)
{
    MD1U16 = A;
    MD5U16 = B;
    ARCON = MUL_16BITX2;
    OPCON = 1;
    while((OPCON & 1) != 0);
    return MD3U32;
}
#endif
